package com.cloud.feign.feign.service;

import com.cloud.feign.feign.service.back.FeignFallBack;
import com.springcoud.domain.springcouddomain.User;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.Map;

/**
 * path ,对于配置了contextpath的项目添加统一的前缀
 * value:提供服务的application名字，也可以使用url方式，但是并不利于配置
 * fallback：添加对应熔断出错时的保护机制
 */
@FeignClient(value = "client1-service",fallback = FeignFallBack.class,path = "/client")
public interface FeignService {
	//服务中方法的映射路径
	@RequestMapping("/hello")
	String hello();

	@RequestMapping("/user")
	User getFeginUser(@RequestBody User user);

	/**
	 * fegin默认发送post请求，加上RequestParam注解解决
	  @param name
	 * @return
	 */
	@RequestMapping(value = "/name",method = RequestMethod.GET)
	String getName(@RequestParam  String  name);

	@RequestMapping(value = "/getId/{salesmanId}")
	String searchLoaning(@PathVariable("salesmanId") String salesmanId,
						 @RequestParam("loanParam") Map<String,Object> loanParam);



}
